package net.tv90.appserveradmin.controller.common;

import net.tv90.appserveradmin.model.Users;
import net.tv90.appserveradmin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class StaticController {

    @Autowired
    UserService userService;

    @GetMapping("/index")
    public String showIndex(Model model) {
        Users u = userService.getCurrentUser();
        model.addAttribute("currentUser", u == null ? "未登录" : u.getUserId());
        return "index";
    }

    @GetMapping("/")
    public String showIndex2(Model model) {
        Users u = userService.getCurrentUser();
        model.addAttribute("currentUser", u == null ? "未登录" : u.getUserId());
        return "index";
    }

}